import axios from "axios"

export default {
    namespaced: true,
    state: {
        allData: {}
    },
    mutations: {
        updateList(state, { currentCatagtory,list }) { 
            state.allData = {...state.allData,[currentCatagtory]:list}
        }
    },
    actions: {
        async getNewList(cxt, cataId) { 
            console.log(cataId);
            const { data: { data: { results} }} = await axios.get(`http://geek.itheima.net/v1_0/articles?channel_id=${cataId}&timestamp=${Date.now()}`)
            //results是新闻列表
            cxt.commit('updateList',{currentCatagtory:cataId,list:results});
        }
    }
}